package com.xiyu.service.repository.customer.pool;

import com.xiyu.service.model.customer.pool.CustomerPoolRuleDept;
import com.xiyu.service.model.customer.pool.CustomerPoolRuleDeptTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface CustomerPoolRuleDeptRepository extends JRepository<CustomerPoolRuleDept, Long> {
    CustomerPoolRuleDeptTable customerPoolRuleDeptTable = CustomerPoolRuleDeptTable.$;

    default void deleteByRuleAndDept(Long ruleId, List<Long> deptIds){
        sql().createDelete(customerPoolRuleDeptTable)
                .where(customerPoolRuleDeptTable.ruleId().eq(ruleId))
                .whereIf(deptIds != null, () -> customerPoolRuleDeptTable.deptId().notIn(deptIds))
                .execute();
    }


}